package com.example.learn.hwod;

import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Scanner;

public class _35寻找密码 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String[] words = sc.nextLine().split(" ");
        System.out.println(solution(words));
    }

    private static String solution(String[] words) {
        Arrays.sort(words, (a,b)->a.length()!=b.length()?b.length()-a.length():b.compareTo(a));
        HashSet<String> wordSet = new HashSet<>(Arrays.asList(words));
        for (String word : words) {
            int j = word.length() - 1;
            for (; j > 0; j--) {
                String pre = word.substring(0, j);
                if (!wordSet.contains(pre)) {
                    break;
                }
            }
            if (j==0) {
                return word;
            }
        }
        return "";
    }
}
